#include <vector>

using namespace std;

class Solution
{
public:
    vector<int> searchRange(vector<int> &nums, int target)
    {
        int l = 0, r = nums.size() - 1;
        while (l < r)
        {
            int mid = (l + r) >> 1;
            if (nums[mid] >= target)
            {
                r = mid;
            }
            else
            {
                l = mid + 1;
            }
        }

        if (nums.empty() || nums[l] != target)
        {
            return {-1, -1};
        }

        for (r = l; r < nums.size() && nums[r] == target; ++r)
        {
        }
        return {l, r - 1};
    }
};